package com.gem.growingtree.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.gem.growingtree.model.Admin;
import com.gem.growingtree.service.AdminService;

@Controller
public class RegisterController {
	@RequestMapping("/regist")
	public ModelAndView addAdmin(String adminName,String adminPass){
		AdminService as = new AdminService();
		Admin admin = new Admin(adminName,adminPass);
		try {
			if(as.register(admin)){
				return new ModelAndView("/login");
			}
			else{
				return new ModelAndView("/register");
			}
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
